import Vue from "vue";
import VueRouter from "vue-router";

import Home from "../views/Home.vue";
import HomeHead from "../components/homeChild/HomeHead.vue";
import HomeMap from "../components/homeChild/HomeMap.vue";
import HomeProtect from "../components/homeChild/HomeProtect.vue";

import MapExisting from "../components/mapChild/MapExisting.vue";
import MapTotal from "../components/mapChild/MapTotal.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "Home",
    component: Home,
    // redirect: "/homeHead",
    children: [
      { path: "", component: HomeHead },
      { path: "/homeMap",
        component: HomeMap,
        redirect: '/existing',
        children: [
          { path: '/existing', component: MapExisting, },
          { path: '/total', component: MapTotal }
        ]
      },
      { path: "/homeProtect", component: HomeProtect }
    ]
  }
];

const router = new VueRouter({
  // mode: "history",
  base: process.env.BASE_URL,
  routes
});

// router.beforeEach((to, from, next) => {
//   if(to.path == from.path) {
//     console.log('yes')
//     return;
//   }
//   console.log(to.path)
//   next()
// })

export default router;
